package com.sbs.gaoxinqutoilet.dialog.datepicker;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;

import com.sbs.gaoxinqutoilet.R;


/**
 * 作者：author
 * 时间：2017/6/26:11:15
 * 邮箱：
 * 说明：
 */
public class CalenderSelectDialog extends Dialog {

    private ImageView iv_left;
    private ImageView iv_right;
    private TextView tv_date;
    private TextView tv_week;
    private TextView tv_today;
    private TextView to_back;
    private TextView to_ready;
    private MonthDateView monthDateView;
    private Dialog mDialog;
    private View mView;
    private Context mContext;
    private String mTime;

    public CalenderSelectDialog(@NonNull Context context,GetDateListener listenre) {
        super(context, R.style.loadingDialogStyle);
        this.mListenre=listenre;
        this.mContext=context;
    }

    public CalenderSelectDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
    }

    protected CalenderSelectDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public CalenderSelectDialog builder(){
        mView= LayoutInflater.from(mContext).inflate(R.layout.activity_date,null);


        to_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDialog.dismiss();
            }
        });
        to_ready.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDialog.dismiss();
                if (mTime!=null&&!mTime.equals(""))
                {
                    mListenre.callBack(mTime);
                }else {
//                    String today = monthDateView.getToday();
//                    mListenre.callBack(today);
                }
            }
        });
        mDialog=new Dialog(mContext,R.style.loadingDialogStyle);
        mDialog.setContentView(mView);
        return this;
    }
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_date);
//        iv_left = (ImageView) findViewById(R.id.iv_left);
//        iv_right = (ImageView) findViewById(R.id.iv_right);
//        monthDateView = (MonthDateView) findViewById(R.id.monthDateView);
//        tv_date = (TextView) findViewById(R.id.date_text);
//        tv_week  =(TextView) findViewById(R.id.week_text);
//        tv_today = (TextView) findViewById(R.id.tv_today);
//        monthDateView.setTextView(tv_date,null);
//        monthDateView.setDateClick(new MonthDateView.DateClick() {
//
//            @Override
//            public void onClickOnDate() {
//                String finalTime = getFinalTime();
//                mListenre.callBack(finalTime);
//            }
//        });
//
//
//
//    }
//    private String getFinalTime() {
//        StringBuffer sb = new StringBuffer();
//        sb.append(monthDateView.getmSelYear()).append("-")
//                .append(monthDateView.getmSelMonth()).append("-")
//                .append(monthDateView.getmSelDay());
//        return sb.toString();
//    }
    public interface GetDateListener{
        public void callBack(String msg);//具体方法
    }

    private GetDateListener mListenre;

    public void setListenre(GetDateListener listenre) {
        mListenre = listenre;
    }
    public void show() {

        mDialog.show();
    }
}
